package com.mall.action;

import com.github.pagehelper.PageInfo;
import com.mall.bean.Fadeback;
import com.mall.bean.Member;
import com.mall.service.FadebackService;
import com.mall.uitl.JsonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/fadebackController")
public class FadebackController {
    @Autowired
    FadebackService fadebackService;

    @RequestMapping("/queryFadeback")
    public JsonUtil queryFadeback(@Validated Fadeback fadeback, Integer currentPage){
        PageInfo<Fadeback> pageInfo =  fadebackService.queryDataByPage(currentPage,5,fadeback);

        JsonUtil jsonUtil = new JsonUtil();
        jsonUtil.setData(pageInfo);

        return jsonUtil;
    }

    @RequestMapping("/deleteById")
    public JsonUtil deleteById(String fadeback_id){
        int res = fadebackService.deleteById(fadeback_id);

        JsonUtil jsonUtil = new JsonUtil();
        jsonUtil.setMsg("成功");

        return jsonUtil;
    }

    @RequestMapping("/update")
    public JsonUtil update(Fadeback fadeback){
        int res = fadebackService.update(fadeback);

        JsonUtil jsonUtil = new JsonUtil();
        jsonUtil.setMsg("成功");

        return jsonUtil;
    }
}
